# -*- coding: UTF-8 -*-
"""
@Project ：swift-forge-engine 
@File    ：upload.py
@IDE     ：PyCharm 
@Author  ：Tony.Gan
@Date    ：2025/3/12 21:47 
@Des     ：
"""

from fastapi import APIRouter, UploadFile
from fastapi.params import File

from App.app.admin.services.upload_service import upload_image
from App.common.respones.response_schema import response_base, ResponseModel
from App.common.security.jwt import DependsJwtAuth

router = APIRouter(prefix="/upload")


@router.post("/avatar", summary="头像上传接口", dependencies=[DependsJwtAuth])
async def upload_avatar(avatar: UploadFile = File(...)) -> ResponseModel:
    """文件上传接口"""
    path = await upload_image(files=avatar, _type="avatar")
    return response_base.success(data=path)


@router.post("/logo", summary="logo上传接口", dependencies=[DependsJwtAuth])
async def upload_logo(logo: UploadFile = File(...)) -> ResponseModel:
    """文件上传接口"""
    path = await upload_image(files=logo, _type="logo")
    return response_base.success(data=path)
